package com.zqt.zqt805.service.Impl;

import com.zqt.zqt805.domain.Order;
import com.zqt.zqt805.mapper.OrderMapper;
import com.zqt.zqt805.service.OrderService;
import com.zqt.zqt805.util.AjaxResult;
import com.zqt.zqt805.util.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public void createOrder(Order order) {
        orderMapper.insertOrder(order);

    }

    @Override
    public Order getOrderById(int orderId) {
        Order order = orderMapper.selectOrderById(orderId);
        return order;

    }

    @Override
    public void updateOrderStatus(int orderId, String status) {
        Order order = orderMapper.selectOrderById(orderId);
        if (order != null) {
            order.setStatus(status);
            orderMapper.updateOrderStatus(order);
        }

    }

    @Override
    public List<Order> getAllOrders() {
        List<Order> orderList = orderMapper.selectAllOrders();
        return orderList;
    }
}